<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:body>
        <p:dialog header="Add Receipt" widgetVar="newReceiptcarDialog2" resizable="false" id="newReceiptDialog"
                  showEffect="fade" hideEffect="explode" modal="true" >
            <h:form id="frmNewReceiptDialog">
                <p:messages id="newReceiptmsgs"/>

                <table id="newReceiptdisplay2" columns="9">
                    <tr>
                        <td><h:outputLabel for="newReceiptreceivedBy" value="Received By: *" /></td>
                        <td><p:autoComplete id="newReceiptreceivedBy" dropdown="true" value="#{receiptBackBean.selectedReceipt.receivedBy}"
                                            completeMethod="#{receiptBackBean.searchUser}" forceSelection="true" required="true"/></td>
                        <td><p:message for="newReceiptreceivedBy" id="newReceiptmsgreceivedBy" display="icon"/></td>

                        <td><h:outputLabel for="newReceiptdeliveredBy" value="Delivered By: " /></td>
                        <td><p:inputText id="newReceiptdeliveredBy" value="#{receiptBackBean.selectedReceipt.deliveredBy}" label="Delivered By:" size="30">
                                <f:validateLength minimum="4"/>
                            </p:inputText>
                        </td>
                        <td><p:message for="newReceiptdeliveredBy" id="newReceiptmsgdeliveredBy" display="icon"/></td>
                        
                        <td><h:outputLabel for="newReceiptshipper" value="Shipper: *" /></td>
                        <td><p:autoComplete id="newReceiptshipper" dropdown="true" value="#{receiptBackBean.selectedReceipt.shipper}"
                                            completeMethod="#{receiptBackBean.searchShipper}" forceSelection="true" required="true"/></td>
                        <td><p:message for="newReceiptshipper" id="newReceiptmsgShipper" display="icon"/></td>
                    </tr>
                    
                    <tr>
                        <td><h:outputLabel for="newReceiptconsignee" value="Consignee: *" /></td>
                        <td><p:autoComplete id="newReceiptconsignee" dropdown="true" value="#{receiptBackBean.selectedReceipt.consignee}"
                                            completeMethod="#{receiptBackBean.searchConsignee}" forceSelection="true" required="true" /></td>
                        <td><p:message for="newReceiptconsignee" id="newReceiptmsgConsignee" display="icon"/></td>

                        <td><h:outputLabel for="newReceiptdescription" value="Description: " /></td>
                        <td><p:inputText id="newReceiptdescription" value="#{receiptBackBean.selectedReceipt.description}" label="Description:" size="30"/></td>
                        <td><p:message for="newReceiptdescription" id="newReceiptmsgDescription" display="icon"/></td>

                        <td><h:outputLabel for="newReceiptpickup" value="Pickup: " /></td>
                        <td><p:inputText id="newReceiptpickup" value="#{receiptBackBean.selectedReceipt.pickup}" >
                                <f:convertNumber integerOnly="true"/>
                            </p:inputText>
                        </td>
                        <td><p:message for="newReceiptpickup" id="newReceiptmsgPickup" display="icon"/></td>
                    </tr>
                    
                    <tr>
                        <td><h:outputLabel for="newReceipthasInvoice" value="Has Invoice: " /></td>
                        <td><h:selectBooleanCheckbox id="newReceipthasInvoice" value="#{receiptBackBean.selectedReceipt.hasInvoice}"/></td>
                        <td><p:message for="newReceipthasInvoice" id="newReceiptmsghasInvoice" display="icon"/></td>
                        
                        <td><h:outputLabel for="status" value="Status: " /></td>
                        <td>
                            <p:selectOneMenu id="status" value="#{receiptBackBean.selectedReceipt.status}">  
                                <f:selectItems value="#{receiptBackBean.receiptStatusValues}" var="t" 
                                           itemValue="#{t.label}" itemLabel="#{t.label}"/>
                            </p:selectOneMenu>
                        </td>
                        <td><p:message for="status" id="msgType" display="icon"/></td>                            
                    </tr>
                </table>

                <p:separator/>

                <p:dataTable id="detailTableId2" var="receiptDetail" value="#{receiptBackBean.selectedReceipt.receiptDetails}" style="width: 300px">

                    <p:column headerText="Quantity">
                        <h:outputText value="#{receiptDetail.quantity}"/>
                    </p:column>

                    <p:column headerText="Vol Height">
                        <h:outputText value="#{receiptDetail.volHeight}"/>
                    </p:column>

                    <p:column headerText="Vol Lenght">
                        <h:outputText value="#{receiptDetail.volLenght}"/>
                    </p:column>

                    <p:column headerText="Vol Width">
                        <h:outputText value="#{receiptDetail.volWidth}"/>
                    </p:column>

                    <p:column headerText="Weight">
                        <h:outputText value="#{receiptDetail.weight}"/>
                    </p:column>
                    <p:column headerText="Type">
                        <h:outputText value="#{receiptDetail.type}"/>
                    </p:column>

                    <p:column style="width:4%">
                        <p:commandButton id="editDetailButton2" update=":newReceiptcarDialog2" oncomplete="newReceiptDetailDialog.show();" icon="ui-icon-pencil" title="Edit">
                            <f:setPropertyActionListener value="#{receiptDetail}" target="#{receiptBackBean.selectedReceiptDetail}" />  
                        </p:commandButton>
                    </p:column>
                </p:dataTable>

                <p:commandButton id="addDetailButton" value="Add Receipt Detail" update=":frmNewReceiptDetailDialog:newReceiptDetaildisplay2" actionListener="#{receiptBackBean.addReceiptDetail}" oncomplete="newReceiptDetailDialog.show();" icon="ui-icon-plusthick" title="Add Detail"/>

                <p:separator/>

                <p:commandButton value="Save" type="submit" update="frmNewReceiptDialog" actionListener="#{receiptBackBean.saveReceipt}" icon="ui-icon-check"/>  
                <p:commandButton value="Close" 
                                 type="submit" 
                                 onclick="newReceiptcarDialog2.hide();" 
                                 label="Close" 
                                 process="@this" 
                                 actionListener="#{receiptBackBean.reset}" 
                                 title="Close" 
                                 update="frmNewReceiptDialog" 
                                 icon="ui-icon-close"/>
            </h:form>    
        </p:dialog>
    </h:body>

</html>
